#include<iostream>
#include<climits>
using namespace std;
int b[26];
int main()
{
	string s;cin>>s;
	int left=0,right=0,n=s.size(),k=0;
	int ret=INT_MAX;
	while(right<n)
	{
		if(b[s[right]-'a']++==0)
		{
			k++;
		}
		while(k>=26)
		{
			ret=min(ret,right-left+1);
			if(--b[s[left]-'a']==0)
			{
				k--;
			}
			left++;
		}
		right++;
	}
	if(ret==INT_MAX) ret=-1;
	cout<<ret<<endl;
}